<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<title>编辑任务</title>
	<link rel="stylesheet" href="css/bootstrap.min.css" />
	<link rel="stylesheet" href="css/jquery-ui-1.8.18.custom.css" />
  <script type="text/javascript" src="js/jquery.js"></script>
  <script type="text/javascript" src="js/jquery-ui-1.8.18.custom.min.js"></script>
  <script type="text/javascript" src="js/bootstrap.min.js"></script>
</head>
<body>
	<%@ include file="include/topbar.jsp" %>
	<div class="container" style="margin-top: 60px;" >
			<div class="row">
	
				<jsp:include page="include/left.jsp" >
					<jsp:param value="goal" name="tag"/>
				</jsp:include>
      <div class="span9 " >
      <ul class="breadcrumb" style="margin-bottom:0px;margin-top:0px;border-radius:3px 3px 0 0;">		
				<li >
					<h4>编辑任务</h4>
				</li>
			</ul>
     
      <form class="wall" style="border-radius: 0 0 3px 3px;padding-left:150px">
          <div class="control-group" id="div01">
            <label for="input01" class="control-label">任务名称</label>
            <div class="controls">
              <input type="text" id="input01" class="input-xlarge" value="${task.name}" />
              
            </div>
          </div>
           <div class="control-group" id="div02">
           <label for="input01" class="control-label">负责人</label>
              <select id="select01">
              <option>请选择开发人员</option>
              <c:forEach var="employee" items="${requestScope.emList}">
              	<option id="${employee.id}">${employee.name}</option>
              	</c:forEach>
	              </select>
	         </div>
          
          <div class="control-group" id="div03">
            <label for="input02" class="control-label">开始时间</label>
            <div class="controls">
            <input type="text" id="datepicker01" value="${task.beginTime}" />
            </div>
          </div>
          
		   <div class="control-group" id="div04">
            <label for="select03" class="control-label">截止时间</label>
            <div class="controls">
            <input type="text" id="datepicker02" value="${task.endTime}" />
            </div>
          </div>
		   <div class="control-group" id="div05">
            <label for="select02" class="control-label">任务状态</label>
            <div class="controls">
              <select id="select02">
                <option>新任务</option>
                <option>进行中</option>
                <option>已完成</option>
              </select>
            </div>
          </div>
		   <div class="control-group" id="div06">
            <label for="select03" class="control-label">任务级别</label>
            <div class="controls">
              <select id="select03">
                <option>重要不紧急</option>
                <option>紧急不重要</option>
                <option>紧急重要</option>
                <option>不紧急不重要</option>
              </select>
            </div>
          </div>
          
          <div class="control-group" id="div07">
            <label for="textarea" class="control-label">任务描述</label>
            <div class="controls">
              <textarea rows="3" id="textarea" class="input-xlarge">${task.desc}</textarea>
            </div>
          </div>
          
          <div class="control-grop" style="margin-top: 20px;">
            <a class="btn btn-primary" id="addtask">确认操作</a>
            <a class="btn btn-danger" href="task.jspx?gid=${curgoal.id }">返回</a>
          </div>
        </form>
        </div>
    </div></div>
	<script type="text/javascript">
	$(document).ready(function() {
		var taskId = "${task.id}";
		$("#${task.employeeId}").attr("selected", "true");
		$("option:contains('${task.state}')").attr("selected", "true");
		$("option:contains('${task.level}')").attr("selected", "true");
		
		$(function() {
			$("#datepicker01").datepicker({
				dateFormat: 'yy-mm-dd'
			});
		});
		
		$(function() {
			$("#datepicker02").datepicker({
				dateFormat: 'yy-mm-dd'
			});
		});
		
		$("#addtask").click(function() {
				var taskName = $("#input01").val();
				var empName = $("#select01").val();
				var empId = $("option:contains('"+ empName +"')").attr("id");
				var beginTime = $("#datepicker01").val();
				var endTime = $("#datepicker02").val();
				var state = $("#select02").val();
				var level = $("#select03").val();
				var desc = $("#textarea").val();
				
				if(taskId.trim() == "" || taskName.trim() == "" || empName.trim() == "请选择负责人" || empId.trim() == "" || beginTime.trim() == "" || endTime.trim() == "" || state.trim() == "" || level.trim() == "" || desc.trim() == "") {
					alert("不能为空");
				} else {
					$.ajax({
						url : "edittask.jspx",
						type : "POST",
						data : {
							taskId : taskId,
							taskName : taskName,
							empId : empId,
							beginTime : beginTime,
							endTime : endTime,
							state : state,
							level : level,
							desc : desc
						}
					}).done(function(msg) {
						if(msg == 1) {
							window.location="task.jspx?gid=${curgoal.id}";
						} else {
							alert("修改失败");
						}
					});
				} 
		});
	});
</script>
</body>
</html>
